/**
 * 
 */
package cc.comac.mom.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.EquipPartBorrowService;
import cc.comac.mom.bean.EquipPartBorrow;
import cc.comac.mom.bean.EquipPartBorrowBean;
import cc.comac.mom.bean.EquipPartBorrowDetail;
import cc.comac.mom.bean.EquipPartBorrowDetailBean;
import cc.comac.mom.bean.ResultDev;
import cc.comac.mom.util.ResultBean;
import io.swagger.annotations.ApiOperation;

/**
* @Description: 
* @author: fyt 
* @date: 2020年7月16日下午9:33:11
*/
@RestController
@RequestMapping(value ="/EquipPartBorrow")
public class EquipPartBorrowController {

	@Autowired
	private EquipPartBorrowService equipPartBorrowService;
	
	@RequestMapping(value = "/save",method = RequestMethod.POST)
	public ResultBean save(@RequestBody EquipPartBorrow obj) {
			ResultBean resultBean = equipPartBorrowService.save(obj);
	
		return resultBean;
	}

	@RequestMapping(value = "/update",method = RequestMethod.POST)
	public ResultBean update(@RequestBody EquipPartBorrow obj) {
			ResultBean resultBean = equipPartBorrowService.update(obj);
		
		return resultBean;
	}
	
	@RequestMapping(value = "/selectByFields",method = RequestMethod.POST)
	public ResultBean selectByFields(@RequestBody EquipPartBorrowBean obj) {
		ResultBean resultBean = new ResultBean(true);
		ResultDev resultDev = equipPartBorrowService.selectByFields(obj);
		resultBean.setObject(resultDev);
		return resultBean;
		
	}
	
	@ApiOperation(value = "删除领用单，以及领用详情")
	@RequestMapping(value = "/deleteBatchEquipPartBorrow",method = RequestMethod.POST)
	public ResultBean deleteBatchEquipPartBorrow(@RequestBody List<EquipPartBorrow> list) {
		
			ResultBean resultBean = equipPartBorrowService.deleteBatch(list);
		return resultBean;
	}
	
	@ApiOperation(value = "领用确认")
	@RequestMapping(value = "/borrowConfig",method = RequestMethod.POST)
	public ResultBean borrowConfig(@RequestBody List<Long> ids) {
			 ResultBean resultBean = equipPartBorrowService.borrowConfig(ids);
	
		return resultBean;
	}
	
	@ApiOperation(value = "根据领用单id获取领用详情")
	@RequestMapping(value = "/selectBorrowDetailByFields",method = RequestMethod.POST)
	public ResultBean selectBorrowDetailByFields(@RequestBody EquipPartBorrowDetailBean obj) {
		ResultBean resultBean = new ResultBean(true);
		ResultDev resultDev = equipPartBorrowService.selectBorrowDetailByFields(obj);
		resultBean.setObject(resultDev);
		return resultBean;
		
	}
	
	@ApiOperation(value = "批量删除领用子项信息")
	@RequestMapping(value = "/deleteBatchBorrowDetail",method = RequestMethod.POST)
	public ResultBean deleteBatchBorrowDetail(@RequestBody List<EquipPartBorrowDetail> list) {
		return equipPartBorrowService.deleteBatchBorrowDetail(list);
	}
}
